// JavaScript Document
//截取指定长度字符串
function sliceString(str,slen,elen){
	if(isNull(str) || typeof(str)!= "string"){return "";}
	if(!(isNumber(slen) && isNumber(elen))){return "";}
	return str.slice(slen,elen+slen);
}
//判断是否为数字
function isNumber(val) {
    var regPos = /^\d+(\.\d+)?$/; //非负浮点数
    var regNeg = /^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$/; //负浮点数
    if(regPos.test(val)){// || regNeg.test(val)) {
        return true;
        } else {
        return false;
        }
    }
//判断NULL
function isNull(val){
	if (typeof(val)=="undefined"){return true;}
	if (val==null){return true;}
	return false;
}
//替换NULL对象
function nullTOstr(str,ostr){
	if(isNull(ostr) || typeof(ostr) != "string"){ostr=""}
	return isNull(str) ? ostr : str;
	}

//获取get参数值
function GetQueryString(name) {
	 var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
	 var r = window.location.search.substr(1).match(reg);
	 if(r!=null)return  unescape(r[2]); return null;
}
//获取URL参数,unescape解码
function getparameter(name){
	var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
	var r = window.location.search.substr(1).match(reg);
	if(r == null) return "";
	return unescape(r[2]);
}
//编码url参数，escape编码
function coded(urlstr){
	return escape(urlstr);
}
// ajax,返回json数据，注释了传入json参数对象
//post
function postJsonAjax(posturl,autodata,async,backfunction){
	//autodata=JSON.stringify(autodata);
	var ajaxObject= postAjaxObject(posturl,autodata,async,backfunction);
	ajaxObject.contentType="application/json; charset=utf-8";
	$.ajax(ajaxObject);
}
function getJsonAjax(geturl,autodata,async,backfunction){
	//autodata=JSON.stringify(autodata);
	var ajaxObject= getAjaxObject(geturl,autodata,async,backfunction);
	ajaxObject.contentType="application/json; charset=utf-8";
	$.ajax(ajaxObject);
}

function postAjaxObject(posturl,autodata,async,backfunction){
	var ajaxObject= {  
	  url:posturl,data:autodata,type:'post',cache:false,dataType:'json',async:async,
	  success:function(data) {backfunction(true,data);},  
	  error : function(XMLHttpRequest, textStatus, errorThrown) {backfunction(false,null);}  
	};
	return ajaxObject;
}
function getAjaxObject(posturl,autodata,async,backfunction){
	var ajaxObject= {  
	  url:posturl,data:autodata,type:'get',cache:false,dataType:'json',async:async,
	  success:function(data) {backfunction(true,data);},  
	  error : function(XMLHttpRequest, textStatus, errorThrown) {backfunction(false,null);}  
	};
	return ajaxObject;
}
//默认ajax传入json参数对象
function appData(){
	return {};
}
//下载app按键
$().ready(function(){});